<?php
namespace app\article\controller;

use app\common\controller\AdminBase;
use think\Loader;

/**
 * 文章分类后台管理控制器
 * @author Yel    2019/7/26
 * @copyright  yel
 */

class ArticleCate extends AdminBase{
	/**
	 * 文章分类列表
	 * @author Yel    2019/7/28
     * @copyright  yel
	 */
	public function lst(){
		//实例化文章分类模型
		$ArticleCate = model('ArticleCate');
		//查询所有数据
		$data = $ArticleCate->selectData([],'id,name,pid,img,tag,sort,status','sort desc,id asc');

		//引入拓展类
		Loader::import('Org.Arraysets',EXTEND_PATH);

		//实例化
		$Arraysets = new \Arraysets;

		//按照树的形式输出
		$data = $Arraysets->getTree($data);

		//判断是否有子级
		foreach ($data as $key => $value) {
			$data[$key]['child'] = $Arraysets->haveChild($value['id'],$data,'pid');
		}
		//数据输出
		$this->assign('data',$data);
		return view('lst');
	}

	/**
	 * 添加文章分类
	 * @author Yel    2019/7/28
     * @copyright  yel
	 */
	public function add(){
		$pid = input('param.pid','');
		$this->assign('pid',$pid);
		return view('add');
	}

	/**
	 * 修改文章分类
	 * @author Yel    2019/7/28
     * @copyright  yel
	 */
	public function edit(){
		
		return view('edit');
	}


	/**
	 * 文章分类删除
	 * @author Yel    2019/7/28
     * @copyright  yel
	 */
	public function del(){
		
		
	}


	/**
	 * 文章分类排序
	 * @author Yel    2019/7/28
     * @copyright  yel
	 */
	public function saveSort(){
		
		
	}


}